﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class TeamsMapping : IEntityTypeConfiguration<Teams>
    {
        public void Configure(EntityTypeBuilder<Teams> builder)
        {
            builder.ToTable("Teams");
            builder.HasKey(t => t.TeamId);
            builder.Property(t => t.TeamId)
                .HasComment("班组主键，自动编号");

            builder.Property(t => t.TeamName)
                .IsRequired()
                .HasColumnType("varchar(30)")
                .HasComment("班组名称，不能重复");

            builder.Property(t => t.TeamContact)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("班组主要负责人，外键（Users）");

            builder.Property(t => t.Status)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(0)
                .HasComment("数据状态（0正常，1删除），默认值0");

            builder.Property(t => t.CreateUserId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("创建人，外键（Users）");

            builder.Property(t => t.CreateTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(t => t.LastUpdateUserId)
                .HasColumnType("int")
                .HasComment("最后一次修改人，外键（Users）");

            builder.Property(t => t.LastUpdateTime)
                .HasColumnType("datetime")
                .HasComment("最后一次修改时间");
        }
    }

}
